package ZuoYe.K;

import Ad.Test01;

import java.io.*;

public class Zuo {
    public void testInputStream(){
    FileInputStream fis = null;
        try {
        fis = new FileInputStream("1.txt");
        int i = 0;
        byte[] a = new byte[1024];
        while ((i = fis.read(a))!= -1){
            System.out.print(new String(a,0,i));
        }
    } catch (
    FileNotFoundException e) {
        e.printStackTrace();
    } catch (
    IOException e) {
        e.printStackTrace();
    } finally {
        if (fis!=null){
            try {
                fis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

}
    public void testReader(){
        FileReader fr = null;
        try {
            fr = new FileReader("3.txt");
            BufferedReader br = new BufferedReader(fr);
            String str = null;
            while ((str = br.readLine())!=null){
                System.out.println(str);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }finally{
            if(fr != null) {
                try {
                    fr.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        Zuo Zuo = new Zuo();
        Zuo.testInputStream();
        Zuo.testReader();
    }
}
